from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

# 指定 Edge WebDriver 路径（根据你下载的路径修改）
webdriver_path = "H:\chromedriver64\msedgedriver.exe"

# 启动 Edge 浏览器
driver = webdriver.Edge(executable_path=webdriver_path)
# driver = webdriver.Chrome() #创建浏览器对象
# 2.输入访问地址（URL）
url = r"http://121.43.169.97:8848/pageA.html"
driver.get(url)

# 实例化
action = ActionChains(driver)

# 获取源元素
source = driver.find_element_by_css_selector("#div1")
# 获取元素
target = driver.find_element_by_css_selector("#div2")
sleep(3)
action.drag_and_drop(source, target).perform()
sleep(3)
action.drag_and_drop_by_offset(source,xoffset=300,yoffset=300).perform()